<template>
  <div class="GetPlace">
    上车地点：
    <select v-model="selectedLocation">
      <option value="" disabled selected>请选择上车地点</option>
      <option
        :value="item.id"
        v-for="(item, index) in resultData"
        :key="item.id"
      >
        {{ item.pickup_location }}
      </option>
    </select>
  </div>
</template>

<script setup>
import { onLoad } from "@dcloudio/uni-app";
import { ref, watch } from "vue";
const baseUrl = "/api";

//当前选的地址
const selectedLocation = defineModel();

const resultData = ref([]);
//发送接口请求
onLoad((any) => {
  uni.request({
    url: baseUrl + "/get/list", //仅为示例，并非真实接口地址。
    method: "get",
    success: (res) => {
      resultData.value = res.data.data;
    },
  });
});

watch(selectedLocation, (Place, oldValue) => {
  // console.log(Place)
  console.log(selectedLocation.value);
});
</script>

<style scoped>
.GetPlace {
  display: flex;
  align-items: center;
  margin-top: 1rem;
  margin-left: 1rem;
}

select {
  width: 12.6rem;
  height: 2rem;
}
</style>
